//
//  ZBaseNaviController.m
//  NewProject
//
//  Created by 陈洪鑫 on 2018/4/13.
//  Copyright © 2018年 chenIos. All rights reserved.
//

#import "ZBaseNaviController.h"

@interface ZBaseNaviController ()

@end

@implementation ZBaseNaviController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UINavigationBar appearance] setShadowImage:[UIImage new]];
//    [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc]init]];
    [self.navigationBar setTranslucent:NO];
    self.navigationBar.barTintColor = COLOR_NAV_BAR;
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : COLOR_NAV_TITLE ,NSFontAttributeName : H2}];
     [self.navigationBar setTintColor:[UIColor blackColor]];
    UIView *segmentView = [UIView new];
    segmentView.frame = CGRectMake(0, self.navigationBar.height - 0.5, SCREEN_W, 0.5);
    segmentView.backgroundColor = [UIColor colorWithHexString:@"f2f2f2"];
    [self.navigationBar addSubview:segmentView];
}

/**
 *  拦截导航控制器push进来的多有自控制器
 */
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        
        //        [button sizeToFit];
        
        UIImage *image = [UIImage imageNamed:@"back"];
        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(back)];
        
        
        //让按钮的内容向左偏移20
        //        button.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
        //        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    }else
    {
        
        
    }
    [super pushViewController:viewController animated:animated];
}
-(void)back{
    
    [self popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
